package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.SuppliersBean;
import com.project.mapper.ISuppliersMapper;
import com.project.service.ISuppliersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuppliersServiceImp implements ISuppliersService {
    @Autowired
    private ISuppliersMapper mapper;
    @Override
    public List<SuppliersBean> findAll() {
        return mapper.findByItem(null, null);
    }

    @Override
    public PageInfo<SuppliersBean> findByItem(int pageNO, String name, String scope) {
        PageHelper.startPage(pageNO, PAGESIZE);
        PageInfo<SuppliersBean> pageInfo=PageInfo.of(mapper.findByItem(name, scope));
        return pageInfo;
    }

    @Override
    public void add(SuppliersBean suppliers) {
        mapper.add(suppliers);
    }

    @Override
    public void update(int id, String headMan, String tel) {
    mapper.update(id, headMan, tel);
    }

    @Override
    public SuppliersBean findById(int id) {
        return mapper.findById(id);
    }
}
